package com.visizen.wisdomclass.server.client;

import com.visizen.wisdomclass.server.model.WcEquipment;
import com.visizen.wisdomclass.server.model.WcLogLogin;
import com.visizen.wisdomclass.server.model.WcLogLoginExample;
import org.apache.ibatis.annotations.*;
import org.apache.ibatis.type.JdbcType;

import java.util.List;

public interface WcLogLoginMapper {
    //使用分页查询用户的登录日志
    @Select("SELECT * FROM wc_log_login WHERE user_id=#{userId} limit #{start},#{end}")
    @Results({
            @Result(column = "log_login_id", property = "log_login_id", jdbcType = JdbcType.BIGINT, id = true),
            @Result(column = "user_id", property = "user_id", jdbcType = JdbcType.BIGINT),
            @Result(column = "equip_id", property = "equip_id", jdbcType = JdbcType.BIGINT),
            @Result(column = "log_login_type", property = "log_login_type", jdbcType = JdbcType.INTEGER),
            @Result(column = "log_login_time", property = "log_login_time", jdbcType = JdbcType.TIMESTAMP),
            @Result(property = "equipment", column = "equip_id", one = @One(select = "getEquipment"))
    })
    List<WcLogLogin> selectByCount(@Param("userId") long userId,
                                   @Param("start") int start,
                                   @Param("end") int end);

    //通过uuid查询指定的设备信息
    @Select("SELECT * FROM wc_equipment where equip_id=#{equip_id}")
    WcEquipment getEquipment(String equip_id);


    /**
     * This method was generated by MyBatis Generator. This method corresponds to the database table wc_log_login
     *
     * @mbggenerated
     */
    @SelectProvider(type = WcLogLoginSqlProvider.class, method = "countByExample")
    int countByExample(WcLogLoginExample example);

    /**
     * This method was generated by MyBatis Generator. This method corresponds to the database table wc_log_login
     *
     * @mbggenerated
     */
    @DeleteProvider(type = WcLogLoginSqlProvider.class, method = "deleteByExample")
    int deleteByExample(WcLogLoginExample example);

    /**
     * This method was generated by MyBatis Generator. This method corresponds to the database table wc_log_login
     *
     * @mbggenerated
     */
    @Delete({"delete from wc_log_login",
            "where log_login_id = #{log_login_id,jdbcType=BIGINT}"})
    int deleteByPrimaryKey(Long log_login_id);

    /**
     * This method was generated by MyBatis Generator. This method corresponds to the database table wc_log_login
     *
     * @mbggenerated
     */
    @Insert({
            "insert into wc_log_login (log_login_id, user_id, ",
            "equip_id, log_login_type, ",
            "log_login_time)",
            "values (#{log_login_id,jdbcType=BIGINT}, #{user_id,jdbcType=BIGINT}, ",
            "#{equip_id,jdbcType=BIGINT}, #{log_login_type,jdbcType=INTEGER}, ",
            "#{log_login_time,jdbcType=TIMESTAMP})"})
    int insert(WcLogLogin record);

    /**
     * This method was generated by MyBatis Generator. This method corresponds to the database table wc_log_login
     *
     * @mbggenerated
     */
    @InsertProvider(type = WcLogLoginSqlProvider.class, method = "insertSelective")
    int insertSelective(WcLogLogin record);

    /**
     * This method was generated by MyBatis Generator. This method corresponds to the database table wc_log_login
     *
     * @mbggenerated
     */
    @SelectProvider(type = WcLogLoginSqlProvider.class, method = "selectByExample")
    @Results({
            @Result(column = "log_login_id", property = "log_login_id", jdbcType = JdbcType.BIGINT, id = true),
            @Result(column = "user_id", property = "user_id", jdbcType = JdbcType.BIGINT),
            @Result(column = "equip_id", property = "equip_id", jdbcType = JdbcType.BIGINT),
            @Result(column = "log_login_type", property = "log_login_type", jdbcType = JdbcType.INTEGER),
            @Result(column = "log_login_time", property = "log_login_time", jdbcType = JdbcType.TIMESTAMP)})
    List<WcLogLogin> selectByExample(WcLogLoginExample example);

    /**
     * This method was generated by MyBatis Generator. This method corresponds to the database table wc_log_login
     *
     * @mbggenerated
     */
    @Select({"select",
            "log_login_id, user_id, equip_id, log_login_type, log_login_time",
            "from wc_log_login",
            "where log_login_id = #{log_login_id,jdbcType=BIGINT}"})
    @Results({
            @Result(column = "log_login_id", property = "log_login_id", jdbcType = JdbcType.BIGINT, id = true),
            @Result(column = "user_id", property = "user_id", jdbcType = JdbcType.BIGINT),
            @Result(column = "equip_id", property = "equip_id", jdbcType = JdbcType.BIGINT),
            @Result(column = "log_login_type", property = "log_login_type", jdbcType = JdbcType.INTEGER),
            @Result(column = "log_login_time", property = "log_login_time", jdbcType = JdbcType.TIMESTAMP)})
    WcLogLogin selectByPrimaryKey(Long log_login_id);

    /**
     * This method was generated by MyBatis Generator. This method corresponds to the database table wc_log_login
     *
     * @mbggenerated
     */
    @UpdateProvider(type = WcLogLoginSqlProvider.class, method = "updateByExampleSelective")
    int updateByExampleSelective(@Param("record") WcLogLogin record,
                                 @Param("example") WcLogLoginExample example);

    /**
     * This method was generated by MyBatis Generator. This method corresponds to the database table wc_log_login
     *
     * @mbggenerated
     */
    @UpdateProvider(type = WcLogLoginSqlProvider.class, method = "updateByExample")
    int updateByExample(@Param("record") WcLogLogin record,
                        @Param("example") WcLogLoginExample example);

    /**
     * This method was generated by MyBatis Generator. This method corresponds to the database table wc_log_login
     *
     * @mbggenerated
     */
    @UpdateProvider(type = WcLogLoginSqlProvider.class, method = "updateByPrimaryKeySelective")
    int updateByPrimaryKeySelective(WcLogLogin record);

    /**
     * This method was generated by MyBatis Generator. This method corresponds to the database table wc_log_login
     *
     * @mbggenerated
     */
    @Update({"update wc_log_login",
            "set user_id = #{user_id,jdbcType=BIGINT},",
            "equip_id = #{equip_id,jdbcType=BIGINT},",
            "log_login_type = #{log_login_type,jdbcType=INTEGER},",
            "log_login_time = #{log_login_time,jdbcType=TIMESTAMP}",
            "where log_login_id = #{log_login_id,jdbcType=BIGINT}"})
    int updateByPrimaryKey(WcLogLogin record);
}